import request from '../../utils/request'

/**
 * 添加或者更新文章
 * @param article
 * @returns {Promise<AxiosResponse<any>>}
 */
const addOrUpdateArticleApi = (article) => {
  return request.post('/api/app/article', article)
}

/**
 * 获取全部文章，包括被删除的文章
 * @returns {Promise<AxiosResponse<any>>}
 */
const getArticlesApi = () => {
  return request.get(`/api/admin/article`)
}

/**
 * 根据id获取文章
 * @param articleId
 * @returns {Promise<AxiosResponse<any>>}
 */
const getArticleByIdApi = (articleId) => {
  return request.get(`/api/app/article/${articleId}`, {})
}

/**
 * 根据id删除文章
 * @param articleId
 * @returns {Promise<AxiosResponse<any>>}
 */
const deleteArticleByIdApi = (articleId,deleted) => {
  return request.delete(`/api/admin/article/${articleId}/${deleted}`)
}
export {
  addOrUpdateArticleApi,
  getArticlesApi,
  getArticleByIdApi,
  deleteArticleByIdApi
}
